
.PHONY : $(all)
all:
	make $(TARGET1)
	make $(TARGET2)

CC              := gcc
G++             := g++
AR              := ar

INC             := -I. 
CFLAGS          := 
C++LINK         := -gp -fno-exceptions -fno-rtti
POSTLINK        := -gp

SOURCES1= getopt.c md5.c md5sum.c main.c
OBJECTS1:= $(SOURCES1:.c=.o)
TARGET1=../bin/md5sum
.PHONY : $(TARGET1)
$(TARGET1): $(OBJECTS1)
	$(CC) $(CFLAGS) $(LINK) -o $(TARGET1) $(OBJECTS1) -lc -lm $(POSTLINK)

SOURCES2=getopt.c md5.c md5sum.c

OBJECTS2:= $(SOURCES2:.c=.o)
TARGET2=../lib/libmd5sum.a
.PHONY : $(TARGET2)
$(TARGET2): $(OBJECTS2)
	$(AR) crv $(TARGET2) $(OBJECTS2)
	cp md5sumLib.h ../include/md5sumLib.h 


.PHONY : $(clean)
clean:
	rm -f $(TARGET1) $(OBJECTS1) $(TARGET2) $(OBJECTS2) ../include/md5sumLib.h

%.o: %.cpp
	$(CC) $(CFLAGS) $(C++LINK) $(INC) -o $@ -c $<

%.o: %.c
	$(CC) $(CFLAGS) $(INC) -o $@ -c $<

